namespace Collaboris.Saf.Actions.Moss.Tests.Generated
{
    using Engine.Report;

    using Entities;

    using Microsoft.SharePoint.Publishing;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Moss.Publishing;

    using Saf.Tests;

    using SharePoint.Moss.Publishing;

    /// <summary>
    /// This test was originally generated but has now been tested and verfiied by MJ
    /// </summary>
    [TestClass]
    public class SetPageLayoutTest
    {
        #region Public Methods

        [TestMethod]
        public void SetPageLayout_Test()
        {
            var setpagelayout = new TestAssistant<SetPageLayout, PageLayoutMapping>(
                TestEnvironment.PublishingSite, "SetPageLayoutTestWeb", "BLANKINTERNET#0");

            using (setpagelayout)
            {
                PublishingWeb publishingWeb =
                    PublishingWeb.GetPublishingWeb(setpagelayout.TestWeb);

                PublishingPage oldPage =
                    PublishingPageHelper.GetPage(setpagelayout.FirstEntity.PageName, publishingWeb);

                string layoutName = oldPage.Layout.Name;

                MacroReport doReport = setpagelayout.DoMacro();
                
                PublishingPage page = 
                    PublishingPageHelper.GetPage(setpagelayout.FirstEntity.PageName, publishingWeb);

                Assert.IsTrue(page.Layout.Name.ToLower() == setpagelayout.FirstEntity.PageLayout.ToLower());
                MacroReport unDoReport = setpagelayout.UndoMacro();

                PublishingPage oldPage1 =
                    PublishingPageHelper.GetPage(setpagelayout.FirstEntity.PageName, publishingWeb);

                Assert.IsTrue(oldPage1.Layout.Name.ToLower() == layoutName.ToLower());

            }
        }

        #endregion
    }
}